package weaver.batchchanges.cmd;

import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import weaver.conn.RecordSet;
import weaver.batchchanges.bean.BatchTasksChangesGlobalData;

import java.util.HashMap;
import java.util.List;

public class DeleteBatchTasksChangesTempDataCmd extends AbstractCommonCommand<Boolean> {

    public DeleteBatchTasksChangesTempDataCmd(List<String> ids) {
        params=new HashMap<>();
        params.put("ids", ids);
    }

    @Override
    public BizLogContext getLogContext() {
        return null;
    }

    @Override
    public Boolean execute(CommandContext commandContext) {
        RecordSet rs = new RecordSet();

        String sql = "delete from " + BatchTasksChangesGlobalData.TEMPORARY_TASK_LEDGER_TABLE_NAME + " where id in (" + String.join(",", (List<String>) params.get("ids")) + ")";
        return rs.execute(sql);
    }
}
